﻿/* * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：超级管理员
 * 日  期：2020-12-04 11:05
 * 描  述：流程分类
 */
var refreshGirdData;
var parentPage = $(parent.document).find("li .lr-frame-iframe,.active")[3].contentWindow;
var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            page.initGird();
            page.bind();
        },
        bind: function () {
            // 刷新
            $('#lr_refresh').on('click', function () {
                refreshGirdData();
            });
            //查询
            $('#btn_Search').on('click', function () {
                var keyword = $('#txt_Keyword').val();
                page.search({ keyword: keyword });
            });
            // 新增
            $('#lr_add').on('click', function () {
                learun.layerForm({
                    id: 'CategoryAdd',
                    title: '新增',
                    url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/CategoryForm',
                    width: 500,
                    height: 300,
                    callBack: function (id) {
                        parentPage.isCaoz = true;
                        return top[id].acceptClick(refreshGirdData);
                    }
                });
            });
            // 编辑
            $('#lr_edit').on('click', function () {
                var keyValue = $('#gridtable').jfGridValue('FlowClassifyID');
                if (learun.checkrow(keyValue)) {
                    learun.layerForm({
                        id: 'CategoryEdit',
                        title: '编辑',
                        url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/CategoryForm?keyValue=' + keyValue ,
                        width: 600,
                        height: 400,
                        callBack: function (id) {
                            parentPage.isCaoz = true;
                            return top[id].acceptClick(refreshGirdData);
                        }
                    });
                }
            });
            // 删除
            $('#lr_delete').on('click', function () {
                var keyValue = $('#gridtable').jfGridValue('FlowClassifyID');
                if (learun.checkrow(keyValue)) {
                    learun.layerConfirm('是否确认删除该项！', function (res) {
                        if (res) {
                            learun.deleteForm(top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/CategoryDeleteEntity', { keyValue: keyValue }, function () {
                                refreshGirdData();
                                parentPage.isCaoz = true;
                            });
                        }
                    });
                }
            });
        },
        // 初始化列表
        initGird: function () {
            var tbalewidth = $('#gridtable').width() / 2;
            $('#gridtable').jfGrid({
                url: top.$.rootUrl + '/LR_NewWorkFlow/NWFScheme/GetCategoryList',
                headData: [
                    { label: '分类名称', name: 'ClassifyName', width: tbalewidth, align: 'left' },
                ],
                mainId: 'FlowClassifyID',
                reloadSelected: true
            });
            page.search();
        },
        search: function (param) {
            param = param || {};
            $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
        }
    };
    refreshGirdData = function () {
        $('#gridtable').jfGridSet('reload');
    };
    page.init();
}
